<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>ZhongKui WAF登录</title>
		<!-- 样 式 文 件 -->
		<link rel="stylesheet" href="component/pear/css/pear.css" />
		<link rel="stylesheet" href="admin/css/other/login.css" />
	</head>
    <!-- 代 码 结 构 -->
	<body style="background-size: cover;">
		<form class="layui-form" action="javascript:void(0);" lay-filter="form_login">
			<div class="layui-form-item">
				<img class="logo" src="admin/images/logo.png" />
				<div class="title">ZhongKui WAF</div>
				<div class="desc">
					妖 魔 鬼 怪 快 离 开
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-wrap">
				  <div class="layui-input-prefix">
					<i class="layui-icon layui-icon-username"></i>
				  </div>
				  <input type="text" name="username" value="" lay-verify="required" placeholder="用户名" lay-reqtext="请填写用户名" autocomplete="off" class="layui-input" lay-affix="clear">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-wrap">
				  <div class="layui-input-prefix">
					<i class="layui-icon layui-icon-password"></i>
				  </div>
				  <input type="password" name="password" value="" lay-verify="required" placeholder="密   码" lay-reqtext="请填写密码" autocomplete="off" class="layui-input" lay-affix="eye">
				</div>
			</div>
			<div class="layui-form-item">
				<button type="button" class="pear-btn pear-btn-success login" lay-submit lay-filter="login" id="btn_login">
					登 录
				</button>
			</div>
		</form>
		<!-- 资 源 引 入 -->
		<script src="component/layui/layui.js"></script>
		<script src="component/pear/pear.js"></script>
		<script>
			layui.use(['form', 'button', 'popup'], function() {
				var form = layui.form;
				var button = layui.button;
				var popup = layui.popup;
				var $ = layui.$;

                // 登 录 提 交
				form.on('submit(login)', function(data) {
					var field = data.field;
					var dom = button.load({
						elem:'.login',
					})
					$.post('/user/login',  field, function(data) {
						if (data && data.code == 200) {
							popup.success("登录成功", function() {
								location.href = "index.html";
							});
						} else {
							popup.failure(data.msg);
							dom.stop();
							return false;
						}
					}, "json");
					return false;
				});

				$(document).on('keydown', function(event) {
					if (event.keyCode === 13) {
						$("#btn_login").trigger("click");
					}
				});
			})
		</script>
	</body>
</html>
